package KC;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;


	public class TextIO {
		
		public static void main(String[] args) throws IOException{
			
			String str = "Esta es una line para probar\n";
			FileWriter fw = new FileWriter("C:\\prueba.txt");

			for (int i = 0; i < str.length(); i++) {
				fw.write(str.charAt(i));
			}
			
			fw.close();
			
			str = "esta es una cadenilla extra";
			fw = new FileWriter("C:\\prueba.txt",true);
			
			for (int i = 0; i < str.length(); i++) {
				fw.write(str.charAt(i));
			}
			
			fw.close();
			
			FileReader fr = new FileReader("C:\\prueba.txt");
			StringBuffer sb = new StringBuffer("");
			int ch = 0;
			while ((ch = fr.read()) != -1){
				sb.append((char)ch);
			}
			System.out.println(sb);
		}

	}